<extend name="Base:main" />
<block name="content">
    <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
                账户金额提现
            </div>
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li>
                <li><a href="#">账户管理</a></li>
                <li class="am-active">账户提现</li>
            </ol>
            <div class="tpl-portlet-components">
                <div class="portlet-title">
                      <div class="caption font-green bold">
                        <span class="am-icon-code"></span>提现
                    </div>
                </div>
                <div class="tpl-block ">

                    <div class="am-g tpl-amazeui-form">
						<style>
							.tx_zh{ width:100%; border:1px solid #fff; }
							.tx_zh dl dd{ width:100%; float:left; line-height:220%; text-indent:1em; cursor:pointer}
							.tx_zh dl dd:hover{ background:#EEFAFF}
							.tx_zh dl dd a{ float:right; display:none;}
							.tx_zh dl dd:hover a{ display:block}
						</style>
						<div class="am-u-sm-12 am-u-md-9">
                             <form class="am-form am-form-horizontal">
							 <div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">收款账户</label>
									<div class="am-u-sm-9 float_left">
										<div class="tx_zh">
											<dl>
												<volist name="account_list" id="vo">
												<dd id="account_list_dd_{$vo.id}"><a href="{:U('Accunt/payAccuntDelete' , array('id' => $vo['id']))}" request_type="ajax" call_func="call_func_delete" style="margin-right:10px;" menu="tip_menu" title="是否要删除这条信息？">[删除]</a><a href="{:U('Accunt/payAccuntSave', array('id' => $vo['id']))}" width="600" height="400" menu="load_iframe_url" data-id="{$vo.id}" title="修改提现账户信息">[修改]</a><input type="radio" name="take_account_id" value="{$vo.id}">&nbsp;&nbsp;&nbsp;{$vo.account_name}&nbsp;&nbsp;&nbsp;{$vo.account_no}</dd>
												</volist>
											</dl>
											<div style="clear:both"></div>
										</div>
										<button style=" margin-left:20px;" href="{:U('Accunt/payAccuntAdd')}" title="增加提现账户" width="600" height="400" menu="load_iframe_url">增加提现账户</button>
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">提现金额</label>
									<div class="am-u-sm-4 float_left">
									<input type="text" onblur="var re = /^[0-9]+$/; if( !re.test(this.value) || parseInt( this.value ) < 0 || parseInt( this.value ) > {:intval( $local )} ) this.value = 1;" id="money" value="1" placeholder="提现金额">
									<small >注意：当前共可提现 <span style="color:red; font-size:16px;">{$local}</span> 元</small>
									</div>
							</div>
							<div class="am-form-group">
									<label for="user-email" class="am-u-sm-3 am-form-label">备注</label>
									<div class="am-u-sm-4 float_left">
									<textarea id="note" placeholder="备注，可不填"></textarea>
									</div>
							</div>
							<div class="am-form-group">
								<div class="am-u-sm-9 am-u-sm-push-3">
									<button type="button" id="ok_submit_pay" title="确认支付" class="am-btn am-btn-primary">确认提现</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
        </div>
		<script>
			$('#ok_submit_pay').click(function(){
				var obj = $("input[name='take_account_id']:checked");
				if( obj.length <= 0 ) {
					error('请选择您需要提现的收款账户！');
					return false;
				}
				var account_id = obj.val();
				var money = $("#money").val();
				var note = $("#note").val();
				$.post("{:U('Accunt/customerWithdrawals')}",{account_id:account_id,money:money,note:note},function(data){
					if( data.status == 1 ) {
						success(data.info,function(opt){ 
							location.href = "{:U('Accunt/local')}";
						});
					} else {
						error( data.info );
					}
				},"json");
				
			});
			function call_func_delete( obj , data ) {
				obj.parent().remove();
			}
			function takeAccuntSave( data ) {
				$("#account_list_dd_" + data.id).html("<a href=\""+getUrl('Accunt/payAccuntDelete' , {'id':data.id})+"\" request_type=\"ajax\" call_func=\"call_func_delete\" style=\"margin-right:10px;\" menu=\"tip_menu\" title=\"是否要删除这条信息？\">[删除]</a><a href=\""+getUrl('Accunt/payAccuntSave', {'id':data.id})+"\" width=\"600\" height=\"400\" menu=\"load_iframe_url\" data-id=\""+data.id+"\" title=\"修改提现账户信息\">[修改]</a><input type=\"radio\" name=\"take_account_id\" value=\""+data.id+"\">&nbsp;&nbsp;&nbsp;"+data.account_name+"&nbsp;&nbsp;&nbsp;"+data.account_no);
			}
			function takeAccuntAdd( data ) {
				$('.tx_zh dl').append("<dd id=\"account_list_dd_"+data.id+"\"><a href=\""+getUrl('Accunt/payAccuntDelete' , {'id':data.id})+"\" request_type=\"ajax\" call_func=\"call_func_delete\" style=\"margin-right:10px;\" menu=\"tip_menu\" title=\"是否要删除这条信息？\">[删除]</a><a href=\""+getUrl('Accunt/payAccuntSave', {'id':data.id})+"\" width=\"600\" height=\"400\" menu=\"load_iframe_url\" data-id=\""+data.id+"\" title=\"修改提现账户信息\">[修改]</a><input type=\"radio\" name=\"take_account_id\" value=\""+data.id+"\">&nbsp;&nbsp;&nbsp;"+data.account_name+"&nbsp;&nbsp;&nbsp;"+data.account_no+"</dd>");
			}
		</script>
</block>